middreware (Laravel)
HTTPリクエストをうけたときに、メインの処理をする前/後に処理をかませることができるしくみ
利用シーンの例
For example, Laravel includes a middleware that verifies the user of your application is authenticated. If the user is not authenticated, the middleware will redirect the user to the login screen. However, if the user is authenticated, the middleware will allow the request to proceed further into the application.
A CORS middleware might be responsible for adding the proper headers to all responses leaving your application.
A logging middleware might log all incoming requests to your application.
認証用のmiddlewareを1つ作っていろいろなAPIに適用できる
middlewareの登録はapp/Http/Kernel.phpに行う
APIにいちいちつけるのが面倒なときには、グループに適用できる
順序が重要なときに、優先度もつけることができる